﻿using System;
using System.Collections.Generic;
using System.Text;

using Microsoft.Xna.Framework;

namespace Daybreak.Core.Mathematics
{
    /// <summary>
    /// A Segment is a line that starts at origin and goes only as far as
    /// (origin + delta).
    /// </summary>
    public struct Segment
    {
        public Vector3 Origin;
        public Vector3 Delta;

        public Segment(Vector3 origin, Vector3 delta)
        {
            this.Origin = origin;
            this.Delta = delta;
        }

        public Vector3 GetPoint(float t)
        {
            Vector3 result;
            result.X = t * Delta.X;
            result.Y = t * Delta.Y;
            result.Z = t * Delta.Z;

            result.X += Origin.X;
            result.Y += Origin.Y;
            result.Z += Origin.Z;

            return result;
            //return Origin + t * Delta;
        }

        public void GetPoint(float t, out Vector3 result)
        {
            result.X = t * Delta.X;
            result.Y = t * Delta.Y;
            result.Z = t * Delta.Z;

            result.X += Origin.X;
            result.Y += Origin.Y;
            result.Z += Origin.Z;

        }

        public Vector3 GetEnd()
        {
            Vector3 result;

            result.X = Delta.X + Origin.X;
            result.Y = Delta.Y + Origin.Y;
            result.Z = Delta.Z + Origin.Z;

            return result;

            //return Origin + Delta;
        }

        public void GetEnd(out Vector3 end)
        {
            end.X = Delta.X + Origin.X;
            end.Y = Delta.Y + Origin.Y;
            end.Z = Delta.Z + Origin.Z;

        }

    }
}
